﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace color2gray
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        fileJpeg file = new fileJpeg();
        Color2Gray c2g = new Color2Gray();
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        
        private void openImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Image result = file.openImage(openFileDialog1);
            if (result != null)
            {
                refreshPicture(result);
            }
        }

        private void saveImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            file.saveImage(saveFileDialog1);
        }
        private void refreshPicture(Image picture)
        {
            file.setImage(picture);
            pictureBox1.Image = picture;
        }

        private void applyColor2GrayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                Image picture = file.getImage();
                picture = c2g.applyColor2gray(picture, (int)numericUpDown1.Value, (int)numericUpDown3.Value, (int)numericUpDown2.Value, checkBox1.Checked);
                refreshPicture(picture);
            }
        }

        private void color2GrayToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void fontDialog1_Apply(object sender, EventArgs e)
        {

        }
       
    }
}
